/*
 * @Author: 'zhangkeqq' '2211709169@qq.com'
 * @Date: 2025-08-12 11:20:03
 * @LastEditors: 'zhangkeqq' '2211709169@qq.com'
 * @LastEditTime: 2025-08-20 13:07:37
 * @FilePath: \staticPage\responsiveWeb\src\router\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'index',
      component: () => import('../views/index/index.vue'),
    },
    {
      path: '/home',
      name: 'home',
      component: HomeView,
    },
    {
      path: '/about',
      name: 'about',
      component: () => import('../views/AboutView.vue'),
    },
  ],
  scrollBehavior(to, from, savedPosition) {
    // savedPosition 是 Vue Router 自动记录的滚动位置
    // 当用户点击浏览器后退/前进按钮时会存在
    if (savedPosition) {
      // 恢复之前保存的滚动位置
      return savedPosition
    } else {
      // 否则默认滚动到顶部
      return { top: 0 }
    }
  }
})

export default router
